<template>
  <!-- <div id="index" ref="appRef" class="index_home" :class="{ pageisScale: isScale }"> -->
  <ScaleScreen
    :width="1920"
    :height="1080"
    class="scale-wrap"
    :fullScreen=true
    :selfAdaption="$store.state.setting.isScale"
  >
    <div class="bg">
      <dv-loading v-if="loading">正在玩命加载...</dv-loading>
      <div v-else class="host-body">
        <!-- 头部 s -->
        <div class="d-flex jc-center title_wrap">
          <div class="zuojuxing">
            <div class="session">
              <span class="s1">巡察届次：</span>
              <el-select class="el-select-se" v-model="termId" placeholder="请选择" @change="jieciSelect">
                <el-option
                  v-for="item in jieci"
                  :key="item.id"
                  :label="item.title"
                  :value="item.id">
                </el-option>
              </el-select>
            </div>

          </div>
          <div class="youjuxing"></div>
          <div class="guang"></div>
          <div class="d-flex jc-center">
            <div class="title">
              <img src="~@/assets/img/淄博市智慧巡察综合管理平台.png" alt="">
            </div>
          </div>
          <div class="timers">
            {{ dateYear }} {{ dateWeek }} {{ dateDay }}
          </div>
        </div>
        <!-- 头部 e-->
        <!-- 内容  s-->
        <router-view :termId="termId" :lunci="lunci"></router-view>
        <!-- 内容 e -->
      </div>
    </div>
    <Setting ref="setting" />
  </ScaleScreen>
  <!-- </div> -->
</template>

<script>
import { formatTime } from '../utils/index.js';
import Setting from './setting.vue';
import ScaleScreen from '@/components/scale-screen/scale-screen.vue';
import { getTermCycleTeamTree } from '@/api';

export default {
  components: { Setting, ScaleScreen },
  data() {
    return {
      termId: '',
      jieci: [],
      lunci: [],
      timing: null,
      loading: true,
      dateDay: null,
      dateYear: null,
      dateWeek: null,
      weekday: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
    };
  },
  filters: {
    numsFilter(msg) {
      return msg || 0;
    },
  },
  computed: {},
  created() {
    getTermCycleTeamTree().then(res => {
      if (res.success) {
        this.jieci = [...res.data];
        if (this.jieci.length > 0) {
          for (let index = 0; index < this.jieci.length; index++) {
            const e = this.jieci[index];
            if (e.isCurrentTerm == '1') {
              this.termId = e.id;
            }
          }
          this.termId = this.jieci[0].id;
          this.lunci = this.jieci[0].children;
        }
      }
    });
  },
  mounted() {
    this.timeFn();
    this.cancelLoading();
  },
  beforeDestroy() {
    clearInterval(this.timing);
  },
  methods: {
    // 届选择
    jieciSelect(value) {
      console.log('value', value);
      this.jieci.forEach(element => {
        if (element.id === value) {
          this.lunci = [...element.children];
          console.log('lunci', this.lunci);
        }
      });
    },
    showSetting() {
      this.$refs.setting.init();
    },
    timeFn() {
      this.timing = setInterval(() => {
        this.dateDay = formatTime(new Date(), 'HH: mm: ss');
        this.dateYear = formatTime(new Date(), 'yyyy-MM-dd');
        this.dateWeek = this.weekday[new Date().getDay()];
      }, 1000);
    },
    cancelLoading() {
      let timer = setTimeout(() => {
        this.loading = false;
        clearTimeout(timer);
      }, 500);
    },
  },
};
</script>

<style lang="scss">

.el-table {
  thead {
    tr {
      background-color: rgba(1, 149, 234, 0.3);

    }

    th {
      color: #fff;

    }
  }
 td.el-table__cell{
    border-bottom: 1px solid #00a0e9!important;
  }
  &::before {
    background: transparent;
  }

  background: transparent;

  .el-table__body tr:hover > td.el-table__cell {
    background: transparent;
  }

  tr:hover {
    background: transparent;
  }

  tr, th.el-table__cell {
    background: transparent;
    color: #fff;
  }
}

.dialog {
  background-color: rgba(1, 17, 45, 0.8);
  border-radius: 6px;
  border: solid 1px #327bf5;
}

.label-bg {
  background-image: url('~@/assets/img/组办情况-label.png');
}

.tool-map {
  width: 180px;
  height: 141px;
  padding: 0 16px;

  .header {
    height: 40px;
    font-family: PingFangSC-Semibold;
    font-size: 20px;
    line-height: 40px;
    font-weight: normal;
    font-stretch: normal;
    letter-spacing: 0px;
    color: #ffffff;

    .img {
      width: 18px;
      height: 16px;
      vertical-align: center;
      margin-right: 10px;
    }
  }

  .hr {
    width: 177px;
    height: 3px;
    background: #05a7e7;
  }

  .content {
    display: flex;

    .text {
      width: 93px;
      font-family: MicrosoftYaHei;
      font-size: 15px;
      font-weight: normal;
      font-stretch: normal;
      line-height: 30px;
      letter-spacing: 0px;
      color: #ffffff;
    }

    .num {
      width: 43px;
      font-family: DS-Digital-Bold;
      font-size: 26px;
      font-weight: normal;
      font-stretch: normal;
      line-height: 30px;
      letter-spacing: 0px;
      color: #fff000;

    }

  }
}

@import "./home.scss";
</style>
